from django.db import models
from django.core.validators import MinValueValidator, MaxValueValidator

class Movie(models.Model):
    title = models.CharField(max_length=200)
    description = models.TextField()
    release_year = models.PositiveIntegerField(
        validators=[
            MinValueValidator(1900),
            MaxValueValidator(2100)
        ]
    )
    rating = models.FloatField(
        validators=[MinValueValidator(0.0), MaxValueValidator(10.0)]
    )
    poster = models.ImageField(upload_to='posters/')
    is_trending = models.BooleanField(default=False)
    
    class Meta:
        ordering = ['-release_year']
    
    def __str__(self):
        return self.title
